//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    request_common_para:app.globalData.request_common_para,
    custNotAuditing:{
      list:[]
    },
    isShowMenu: false,
    curMenu: '客户需求',
    menuList: null,
    maxPage:0,
    pageNo:0,
    queryParam: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      menuList:app.globalData.menuListData,
      request_common_para: app.globalData.request_common_para
    })

    let data = this.data.request_common_para
    data.pageBusiCode = "10" //客户列表
    data.pageNo=0
    //data.audit="1"
    let that=this
    wx.request({
      url: app.getHost()+"/datalake/v1/userManages/getMatchUserManages",
      data: data,
      method: "POST",
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function(res) {
        if (res.statusCode == 200) {
          that.setData({
            custNotAuditing: { list: res.data.list} ,
            maxPage:res.data.maxPage,
            pageNo:0
          })
        }
      },
      complete: function(res) {
      },
      fail:function(res){
      }
    });
  },

  searchBox:function(e){
    
    var that = this;
    var data = this.data.request_common_para
    //data.audit = "1"
    data.carModel = e.detail.value
    data.pageBusiCode="10" //客户列表
   
    wx.request({
      url: app.getHost()+ "/datalake/v1/userManages/getMatchUserManages",
      data: data,
      method: "POST",
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        if (res.statusCode == 200) {
          that.setData({
            custNotAuditing: { list: res.data.list },
            maxPage:res.data.maxPage,
            pageNo:0
          })
        }
      },
      complete: function (res) {
        console.info("custInfoList complete :"+res);
      },
      fail:function(res){
        console.error(res);
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {
    app.toast3Tap()
    this.onLoad();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    let maxPage = this.data.maxPage;
    let pageNo = this.data.pageNo;
    if (maxPage > pageNo) {
      pageNo++;
      this.setData({
        pageNo: pageNo
      })
      app.toast3Tap()
      var that = this;
      var data = this.data.request_common_para
      data.pageNo = pageNo
      //data.audit = "1"
      if(this.data.queryParam){
        data.carModel = this.data.queryParam
      }
      data.pageBusiCode = "10" //客户列表
      wx.request({
        url: app.getHost() + "/datalake/v1/userManages/getMatchUserManages",
        data: data,
        method: "POST",
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: function (res) {
          if (res.statusCode == 200) {
            let custNotAuditingList = that.data.custNotAuditing.list
            for (let i in res.data.list) {
              custNotAuditingList.push(res.data.list[i])
            }
            that.setData({
              custNotAuditing: { list: custNotAuditingList },
              maxPage: res.data.maxPage,
              pageNo: pageNo
            })
          }
        },
        complete: function (res) {
          console.info("custInfoList complete :" + res);
        },
        fail: function (res) {
          console.error(res);
        }
      });

    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  bindtapSavaCust:function(e){
    wx.navigateTo({
      url: 'saveCust'
    })
  },
  toggleMenuList: function (e) {
    let { isShowMenu } = this.data;

    this.setData({
      isShowMenu: !isShowMenu
    })
  },
  navigatorPage: function (e) {
    let dataset = e.currentTarget.dataset;
    let pages = getCurrentPages();
    let currPage = pages[pages.length - 1];

    if ('/' + currPage.route == dataset.url) {
      return
    }

    this.setData({
      isShowMenu: false
    })
    wx.reLaunch({
      url: dataset.url
    })
  }
  
})